package vip.web3.admin.sys.dao.biz;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import vip.web3.admin.sys.entity.biz.AOrderEntity;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 订单Mapper接口
 * <p>
 * aut-horlilei
 *
 * @date 2024-09-27
 */
@Mapper
public interface AOrderDao extends BaseMapper<AOrderEntity> {


    /**
     * 批量删除订单
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteAOrderByIds(Integer[] ids);

    @Update("update a_order set status = 1 where status = 0")
    void initStatus();
    //                         query.ne("pro_id", 1);

    @Select("select ifnull(sum(amount_cny),0) from a_order where pro_id != 1 and user_id = #{userId} and create_date " +
            ">= #{start}  and create_date < #{end}")
    BigDecimal selectTotalOrder(@Param("userId") Integer userId,
                                @Param("start") Date start,
                                @Param("end") Date end);

    @Select("select ifnull(sum(amount_cny),0) from a_order where pro_id != 1 and user_id = #{userId}")
    BigDecimal selectTotalOrderUserId(@Param("userId") Integer userId);


    @Select("select ifnull(sum(amount_usdt),0) from a_order where pro_id != 1 and user_id = #{userId}")
    BigDecimal selectTotalOrderUsdt(@Param("userId") Integer userId);

}
